package com.lin.filegraph.utils.comcheck;

import com.lin.filegraph.utils.analyze.ExcelToGraph;
import com.lin.filegraph.utils.compdg.ComponentGraph;
import com.lin.filegraph.utils.componentRule.DetectCouples;
import com.lin.filegraph.utils.componentRule.DetectMultiple;
import com.lin.filegraph.utils.model.ComponentModule;
import com.lin.filegraph.utils.model.Module;

import java.io.File;
import java.util.List;

/**
 * @description:
 * @author: linhuaixu
 * @time: 2023/5/18 15:49
 */

public class ArcOptimize {
    public static void executeOptimize(String excelPath, String projectPath, ComponentGraph cgAuto, List<Module> comList, List<ComponentModule> fileList){
//		ComRename.renameCDG(cgAuto);
//		System.out.println("架构校验——架构输入.....");
//		if(excelPath!=null&&!excelPath.equals("")){
//			if(new File(excelPath).exists()){
//				ComponentGraph cgIn = ExcelToGraph.transform(excelPath, projectPath);
        DesignCheck.checkSame(cgAuto);
//			}else{
//				System.out.println(excelPath+"文件不存在！");
//			}
//		}else {
//			System.out.println("没有检测到架构输入！");
//		}
        System.out.println("架构校验——目录.....");
        DirCheck.executeDirCheck(cgAuto,comList,fileList);
        System.out.println("****紧耦合处理***");
        DetectCouples.removeCouples(cgAuto);
        System.out.println("****component optimize***");
        DetectMultiple.OptimizeMutiComp(cgAuto);
        DetectMultiple.OptimizeMutiComp1(cgAuto);//当组件数目过多的时候，聚合一些小组件
    }
    //在划分目录之前，在强依赖聚合之后
    public static void executeOptimize(String excelPath, String projectPath, ComponentGraph partitionedCompDG) {
        // TODO Auto-generated method stub
//		ComRename.renameCDG(cgAuto);
        System.out.println("架构校验——架构输入.....");
        if(excelPath!=null&&!excelPath.equals("")){
            if(new File(excelPath).exists()){
                ComponentGraph cgIn = ExcelToGraph.transform(excelPath, projectPath);
                DesignCheck.CombineArcDocument(partitionedCompDG, cgIn);
            }else{
                System.out.println(excelPath+"文件不存在！");
            }
        }else {
            System.out.println("没有检测到架构输入！");
        }
        System.out.println("架构文档 help工作完成！！！");

    }
}

